﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using Serie_Counter.Presentatie;

namespace Serie_Counter
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        [PreEmptive.Attributes.Setup(CustomEndpoint = "so-s.info/PreEmptive.Web.Services.Messaging/MessagingServiceV2.asmx")]
        [PreEmptive.Attributes.Teardown()]
        static void Main()
        {
            //use of Mutex to make sure there only can start one instance of the program.
            bool ok;
            Mutex m = new System.Threading.Mutex(true, "SerieCounter", out ok);

            if(!ok)
            {
                MessageBox.Show("Another instance of Serie Counter is already running.","",MessageBoxButtons.OK,MessageBoxIcon.Stop);
                return;
            }
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            
            Application.Run(new TrayForm());

            GC.KeepAlive(m);
        }
    }
}
